package com.tjsinfo.tjsoa.system.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.system.bo.ISystemAllGroupBO;
import com.tjsinfo.tjsoa.system.bo.ISystemPrivateGroupBO;
import com.tjsinfo.tjsoa.system.vo.TSystemAllgroup;
import com.tjsinfo.tjsoa.system.vo.TSystemPrivategroup;

public class EnablePrivateGroupAction extends Action {
	private ISystemPrivateGroupBO systemPrivateGroupBO;
	
	
	



	public ISystemPrivateGroupBO getSystemPrivateGroupBO() {
		return systemPrivateGroupBO;
	}






	public void setSystemPrivateGroupBO(ISystemPrivateGroupBO systemPrivateGroupBO) {
		this.systemPrivateGroupBO = systemPrivateGroupBO;
	}






	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		TSystemPrivategroup systemAllgroup = systemPrivateGroupBO.selectTSystemPrivategroupById(Integer.parseInt(request.getParameter("id")));
		if (systemAllgroup.getState() == 0 ) {
			systemAllgroup.setState(1);
		} else {
			systemAllgroup.setState(0);
		}
		
		 if (systemPrivateGroupBO.updateSystemPrivateGroup(systemAllgroup)) {
		    	JSONObject object = new JSONObject();
		    	object.put("success", true);
				response.getWriter().print(object);
			} else {
				JSONObject object = new JSONObject();
		    	object.put("success", false);
				response.getWriter().print(object);
			}
			
			return null;
	}
}